<!--_meta 作为公共模版分离出去-->
<include file="./Application/Admin/View/_meta.html" />
<body>
<include file="./Application/Admin/View/_header.html" />
<!--/_header 作为公共模版分离出去-->
<include file="./Application/Admin/View/_menu.html" />
<article class="cl pd-20">
	<form action="{$_SERVER['REQUEST_URI']}" class="form form-horizontal" id="aaaaaa" method="post">
		<div class="row cl" style="margin-top: 50px;">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>QQ支付所用通道：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<!--<input type="text" class="input-text" value="" placeholder="" id="adminName" name="adminName">-->
				<select class="select" name="qq_pay" id="qq_pay"  onchange='changeMchId($(this) , $("#qqpay_mchId"))'>
					<foreach name="passageway_qq_pay" item="passageway_qq_pay1">
						<option value="{$passageway_qq_pay1.pay_methodname}" <?php if($qq_pay_conf['mch_channel'] == $passageway_qq_pay1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_qq_pay1.asname}</option>
					</foreach>
					<option value="" <?php if($qq_pay_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>


				<select class="select" name="qq_pay_mchId" id="qqpay_mchId">
					<foreach name="mchconf_qq_pay" item="mchconf_qq_pay_vo">
						<option value="{$mchconf_qq_pay_vo.mch_id}" <?php if($mchconf_qq_pay_vo['mch_id'] == $qq_pay_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_qq_pay_vo.mch_id}({$mchconf_qq_pay_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>支付宝所用通道：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" name="alipay_pay" id="alipay_pay" onchange='changeMchId($(this) , $("#Alipaypay_mchId"))'>
					<foreach name="passageway_alipay_pay" item="passageway_alipay_pay1">
						<option value="{$passageway_alipay_pay1.pay_methodname}" <?php if($alipay_pay_conf['mch_channel'] == $passageway_alipay_pay1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_alipay_pay1.asname}</option>
					</foreach>
					<option value="" <?php if($alipay_pay_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>

				<select class="select" name="alipay_pay_mchId" id="Alipaypay_mchId">
					<foreach name="mchconf_alipay_pay" item="mchconf_alipay_pay_vo">
						<option value="{$mchconf_alipay_pay_vo.mch_id}" <?php if($mchconf_alipay_pay_vo['mch_id'] == $alipay_pay_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_alipay_pay_vo.mch_id}({$mchconf_alipay_pay_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>微信扫码支付：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" name="WeixinScancode" id="WeixinScancode" onchange='changeMchId($(this) , $("#weixinSM_mchId"))'>
					<foreach name="passageway_WeixinScancode" item="passageway_WeixinScancode1">
						<option value="{$passageway_WeixinScancode1.pay_methodname}" <?php if($WeixinScancode_conf['mch_channel'] == $passageway_WeixinScancode1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_WeixinScancode1.asname}</option>
					</foreach>
					<option value="" <?php if($WeixinScancode_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>


				<select class="select" name="WeixinScancode_mchId" id="weixinSM_mchId">
					<foreach name="mchconf_WeixinScancode" item="mchconf_WeixinScancode_vo">
						<option value="{$mchconf_WeixinScancode_vo.mch_id}"   <?php if($mchconf_WeixinScancode_vo['mch_id'] == $WeixinScancode_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_WeixinScancode_vo.mch_id}({$mchconf_WeixinScancode_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>微信公众号支付：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" name="weixinGzh_pay" id="weixinGzh_pay" onchange='changeMchId($(this) , $("#weixinGzh_mchId"))'>
					<foreach name="passageway_weixinGzh_pay" item="passageway_weixinGzh_pay1">
						<option value="{$passageway_weixinGzh_pay1.pay_methodname}" <?php if($weixinGzh_conf['mch_channel'] == $passageway_weixinGzh_pay1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_weixinGzh_pay1.asname}</option>
					</foreach>
					<option value="" <?php if($weixinGzh_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>


				<select  class="select" name="weixinGzh_pay_mchId" id="weixinGzh_mchId">
					<foreach name="mchconf_weixinGzh_pay" item="mchconf_weixinGzh_pay_vo">
						<option value="{$mchconf_weixinGzh_pay_vo.mch_id}"   <?php if($mchconf_weixinGzh_pay_vo['mch_id'] == $weixinGzh_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_weixinGzh_pay_vo.mch_id}({$mchconf_weixinGzh_pay_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>京东钱包所用通道：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" name="jd_pay" id="jd_pay" onchange='changeMchId($(this) , $("#jd_mchId"))'>
					<foreach name="passageway_jd_pay" item="passageway_jd_pay1">
						<option value="{$passageway_jd_pay1.pay_methodname}" <?php if($jd_pay_conf['mch_channel'] == $passageway_jd_pay1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_jd_pay1.asname}</option>
					</foreach>
					<option value="" <?php if($jd_pay_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>

				<select class="select" name="jd_pay_mchId" id="jd_mchId">
					<foreach name="mchconf_jd_pay" item="mchconf_jd_pay_vo">
						<option value="{$mchconf_jd_pay_vo.mch_id}" <?php if($mchconf_jd_pay_vo['mch_id'] == $jd_pay_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_jd_pay_vo.mch_id}({$mchconf_jd_pay_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>网银支付：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" name="bank_pay" id="bank_pay" onchange='changeMchId($(this) , $("#bankpay_mchId"))'>
					<foreach name="passageway_bank_pay" item="passageway_bank_pay1">
						<option value="{$passageway_bank_pay1.pay_methodname}" <?php if($bank_pay_conf['mch_channel'] == $passageway_bank_pay1['pay_methodname']) echo 'selected="selected"';  ?>>{$passageway_bank_pay1.asname}</option>
					</foreach>
					<option value="" <?php if($bank_pay_conf['mch_channel'] == '') echo 'selected="selected"';  ?>>不指定该通道</option>
				</select>


				<select class="select" name="bank_pay_mchId" id="bankpay_mchId">
					<foreach name="mchconf_bank_pay" item="mchconf_bank_pay_vo">
						<option value="{$mchconf_bank_pay_vo.mch_id}"   <?php if($mchconf_bank_pay_vo['mch_id'] == $bank_pay_conf['mch_id']) echo 'selected="selected"';  ?> >{$mchconf_bank_pay_vo.mch_id}({$mchconf_bank_pay_vo.mch_subject})</option>
					</foreach>
				</select>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">指定商户号有效：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box" style="width:150px;">
			<select class="select" name="effective_merchant" id="mch_id_select">
					<option value="0" <?php if($_GET['mch_id'] == '') echo 'selected="selected"'; ?> >所有商户</option>
				<foreach name="merchant_id" item="effective_merchant">
						<?php if($effective_merchant['merchant_id'] == '') continue; ?>
				<option id="{$effective_merchant.id}" value="{$effective_merchant.merchant_id}" <?php if( ($effective_merchant['$effective_merchant'] != '' && I('request.id') == $effective_merchant['id']) || ($effective_merchant['$effective_merchant'] == '' && $effective_merchant['merchant_id'] == I('get.mch_id')) ) echo 'selected="selected"'; ?> >
					商户号：{$effective_merchant.merchant_id} 所属项目：{$effective_merchant.userremarks}
					<if condition="$effective_merchant.id neq '' ">
						有效使用金额：{$effective_merchant.passageway_price}  所属分组：<?php if($effective_merchant['passageway_group'] == 0) {echo '通道分组A';}elseif($effective_merchant['passageway_group'] == 1){echo '通道分组B';}elseif($effective_merchant['passageway_group'] == 2){echo '通道分组C';} ?>
					</if>
				</option>
				</foreach>
			</select>
				</span>	<font color="red">(指定商户号后，该商户的支付将以本次选择的通道为准)</font>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">清空该商户号所有通道：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="checkbox-pinglun" name="empty_merchant" value="1">
					<label for="checkbox-pinglun">&nbsp;</label>
				</div>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">不寻找默认通道：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="check-box">
					<input type="checkbox" value="1" name="continue_merchant" <?php if($continue_merchant == 1) echo 'checked'; ?> >
					<label for="checkbox-pinglun">&nbsp;</label>
				</div>
			</div>
		</div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">新否新加规则：</label>
			<div class="formControls col-xs-8 col-sm-9">
				是：<input type="radio" name="is_add"  value="1" class="radio-box" autocomplete="off" <?php if($_GET['id'] == '') echo 'checked';?> > &nbsp;&nbsp;&nbsp;&nbsp;
				否：<input <?php if(I('get.mch_id') != '' && I('get.id') == '') echo 'disabled'; ?> type="radio" name="is_add" value="0" class="radio-box" autocomplete="off"  <?php if($_GET['id'] != '' ||  $_GET['mch_id'] == '') echo 'checked';?> >
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">满足指定金额：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="number" name="passageway_price" value="{$passageway_price}" class="input-text" autocomplete="off">
				<font color="red">(当请求金额满足时，自动切换到该通道)</font>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">通道配置所属组：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box" style="width:150px;">
					<select name="passageway_group" class="select">
						<option value="0" <?php if($passageway_group == 0) echo 'selected=selected'; ?>>通道分组A</option>
						<option value="1" <?php if($passageway_group == 1) echo 'selected=selected'; ?>>通道分组B</option>
						<option value="2" <?php if($passageway_group == 2) echo 'selected=selected'; ?>>通道分组C</option>
					</select>
				</span>
			</div>
		</div>


		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<include file="./Application/Admin/View/_footer.html" />
</body>

<script type="text/javascript">
	// onchange="location.href = '?mch_id=' + this.value"

    function changeMchId(passageway_change, mchidSelectObj){
        var pay_type = '';
//            $('#MchNametext').html('请选择' + $((this) + "option:selected").html() + '商户号:');
        pay_type = passageway_change.val(); // 用户选择的支付类型
        $(mchidSelectObj).empty();
        $.ajax({
            url: '__CONTROLLER__/passagewayMchidLoad',
            type: 'POST',
            dataType: 'json',
            data: {"pay_type" : pay_type},
            success: function (datas) {
                if(datas.error){
                    layer.alert(datas.msg);
                    return false;
                }
                // 追加option
                for(var i = 0;i < datas.length; i++) {
                    mchidSelectObj.append("<option value='"+ datas[i].mch_id +"'>"+ datas[i].mch_id + "("+ datas[i].mch_subject +")" +"</option>");
                }
            }
        });
    }

    $(function () {
        // 如果页面加载完成后，所有支付类型都为空，那么勾选上empty_merchant checked
        if(($("#qq_pay").val() == '' && $("#alipay_pay").val() == '' && $("#jd_pay").val() == '' && $("#alipay_pay").val() == '' && $("#weixinGzh_pay").val() == '' &&  $("#WeixinScancode").val() == '' && $("#bank_pay").val() == '')){
            $("input[name='empty_merchant']").attr("checked",true);
		}

        $("#mch_id_select").change(function () {
			location.href = '?mch_id=' + $(this)[0].value + '&id=' + $(this).find("option:selected").attr("id") + '&rand=' + Math.random();
        });
        $("#aaaaaa").submit(function(e){
            var _empty_merchant = $("input[name='empty_merchant']").is(':checked');
            if(_empty_merchant == false && ($("#qq_pay").val() == '' && $("#alipay_pay").val() == '' && $("#jd_pay").val() == '' && $("#alipay_pay").val() == '' && $("#weixinGzh_pay").val() == '' &&  $("#WeixinScancode").val() == '' && $("#bank_pay").val() == '')){
                alert('必须选择一个指定通道');
                return false;
            }

            $(this).submit();
        });
    });
</script>
</html>